Dynomotion

Group: DynoMotion Message: 5860 From: himykabibble Date: 10/23/2012
Subject: KMotion Is Laughing At Me Again....
Tom,

My ATC "driver" is working perfectly running a stand-alone test, so I set it up as an M6 handler, using the "Program and Wait" action. But, I've run into a problem. When I run G-code, and it encounters an M6, it loads and runs my driver, but the driver hangs part-way through. The relevent section of code is below. The first printf ("In Grab...") comes out, and shows CheckDone returns 1. The second printf ("Doing Move...") does not come out. It is NOT executing the if and returning. If I hit Stop, to stop the interpreter, then this code picks up and starts running again, like nothing ever happened. So, it appears to be hanging in the if statement, until the interpreter is stopped, which makes no sense to me. Must be something to do with the ReadBits?

void PDBGrab(float turns)
{

printf("In Grab(%d)\n", CheckDoneXYZABC());
if (!CheckDoneXYZABC() ||
ReadBit(DRAWBAR_ACTIVATE) ||
ReadBit(SPINDLE_CW) ||
ReadBit(SPINDLE_CCW) ||
ReadBit(COOLANT_MIST) ||
ReadBit(COOLANT_FLOOD))
return;
printf("@Doing Move\n");
Move(AXIS_Z, -0.025 * B_STEPS_PER_INCH);
printf("@Done\n");
while (!CheckDoneXYZABC())
;
...

Any ideas? This does not happen if the action type is Program, rather than ProgramWait. But, of course, then the interpreter does not wait for the toolchange to complete before moving on.

Regards,
Ray L.
Group: DynoMotion Message: 5861 From: brad murry Date: 10/23/2012
Subject: Re: KMotion Is Laughing At Me Again....
I vaguely recall running into a similar issue trying to debug a homing routine with printfs...  I'd almost wager there is a deadlock happening .

Tom?

-Brad Murry

From: himykabibble
Sent: 10/23/2012 1:09 PM
To: DynoMotion@yahoogroups.com
Subject: [DynoMotion] KMotion Is Laughing At Me Again....

 

Tom,

My ATC "driver" is working perfectly running a stand-alone test, so I set it up as an M6 handler, using the "Program and Wait" action. But, I've run into a problem. When I run G-code, and it encounters an M6, it loads and runs my driver, but the driver hangs part-way through. The relevent section of code is below. The first printf ("In Grab...") comes out, and shows CheckDone returns 1. The second printf ("Doing Move...") does not come out. It is NOT executing the if and returning. If I hit Stop, to stop the interpreter, then this code picks up and starts running again, like nothing ever happened. So, it appears to be hanging in the if statement, until the interpreter is stopped, which makes no sense to me. Must be something to do with the ReadBits?

void PDBGrab(float turns)
{

printf("In Grab(%d)\n", CheckDoneXYZABC());
if (!CheckDoneXYZABC() ||
ReadBit(DRAWBAR_ACTIVATE) ||
ReadBit(SPINDLE_CW) ||
ReadBit(SPINDLE_CCW) ||
ReadBit(COOLANT_MIST) ||
ReadBit(COOLANT_FLOOD))
return;
printf("@Doing Move\n");
Move(AXIS_Z, -0.025 * B_STEPS_PER_INCH);
printf("@Done\n");
while (!CheckDoneXYZABC())
;
...

Any ideas? This does not happen if the action type is Program, rather than ProgramWait. But, of course, then the interpreter does not wait for the toolchange to complete before moving on.

Regards,
Ray L.

Group: DynoMotion Message: 5862 From: himykabibble Date: 10/23/2012
Subject: Re: KMotion Is Laughing At Me Again....
Brad,

I put the printfs to find the root of this problem. Without the printfs, the behavior is the same.

Regards,
Ray L.

--- In DynoMotion@yahoogroups.com, brad murry <bradodarb@...> wrote:
>
> I vaguely recall running into a similar issue trying to debug a homing routine with printfs... I'd almost wager there is a deadlock happening .
>
> Tom?
>
> -Brad Murry
> ________________________________
> From: himykabibble
> Sent: 10/23/2012 1:09 PM
> To: DynoMotion@yahoogroups.com
> Subject: [DynoMotion] KMotion Is Laughing At Me Again....
>
> Tom,
>
> My ATC "driver" is working perfectly running a stand-alone test, so I set it up as an M6 handler, using the "Program and Wait" action. But, I've run into a problem. When I run G-code, and it encounters an M6, it loads and runs my driver, but the driver hangs part-way through. The relevent section of code is below. The first printf ("In Grab...") comes out, and shows CheckDone returns 1. The second printf ("Doing Move...") does not come out. It is NOT executing the if and returning. If I hit Stop, to stop the interpreter, then this code picks up and starts running again, like nothing ever happened. So, it appears to be hanging in the if statement, until the interpreter is stopped, which makes no sense to me. Must be something to do with the ReadBits?
>
> void PDBGrab(float turns)
> {
>
> printf("In Grab(%d)\n", CheckDoneXYZABC());
> if (!CheckDoneXYZABC() ||
> ReadBit(DRAWBAR_ACTIVATE) ||
> ReadBit(SPINDLE_CW) ||
> ReadBit(SPINDLE_CCW) ||
> ReadBit(COOLANT_MIST) ||
> ReadBit(COOLANT_FLOOD))
> return;
> printf("@Doing Move\n");
> Move(AXIS_Z, -0.025 * B_STEPS_PER_INCH);
> printf("@Done\n");
> while (!CheckDoneXYZABC())
> ;
> ...
>
> Any ideas? This does not happen if the action type is Program, rather than ProgramWait. But, of course, then the interpreter does not wait for the toolchange to complete before moving on.
>
> Regards,
> Ray L.
>
Group: DynoMotion Message: 5863 From: himykabibble Date: 10/23/2012
Subject: Re: KMotion Is Laughing At Me Again....
Brad,

I think you're right after all. I found I had accidentally left in a single printf to display the tool number and carousel slot on entry to the M6 program. I removed that, and it's now working correctly. Strange....

Regards,
Ray L.

--- In DynoMotion@yahoogroups.com, brad murry <bradodarb@...> wrote:
>
> I vaguely recall running into a similar issue trying to debug a homing routine with printfs... I'd almost wager there is a deadlock happening .
>
> Tom?
>
> -Brad Murry
> ________________________________
> From: himykabibble
> Sent: 10/23/2012 1:09 PM
> To: DynoMotion@yahoogroups.com
> Subject: [DynoMotion] KMotion Is Laughing At Me Again....
>
> Tom,
>
> My ATC "driver" is working perfectly running a stand-alone test, so I set it up as an M6 handler, using the "Program and Wait" action. But, I've run into a problem. When I run G-code, and it encounters an M6, it loads and runs my driver, but the driver hangs part-way through. The relevent section of code is below. The first printf ("In Grab...") comes out, and shows CheckDone returns 1. The second printf ("Doing Move...") does not come out. It is NOT executing the if and returning. If I hit Stop, to stop the interpreter, then this code picks up and starts running again, like nothing ever happened. So, it appears to be hanging in the if statement, until the interpreter is stopped, which makes no sense to me. Must be something to do with the ReadBits?
>
> void PDBGrab(float turns)
> {
>
> printf("In Grab(%d)\n", CheckDoneXYZABC());
> if (!CheckDoneXYZABC() ||
> ReadBit(DRAWBAR_ACTIVATE) ||
> ReadBit(SPINDLE_CW) ||
> ReadBit(SPINDLE_CCW) ||
> ReadBit(COOLANT_MIST) ||
> ReadBit(COOLANT_FLOOD))
> return;
> printf("@Doing Move\n");
> Move(AXIS_Z, -0.025 * B_STEPS_PER_INCH);
> printf("@Done\n");
> while (!CheckDoneXYZABC())
> ;
> ...
>
> Any ideas? This does not happen if the action type is Program, rather than ProgramWait. But, of course, then the interpreter does not wait for the toolchange to complete before moving on.
>
> Regards,
> Ray L.
>
Group: DynoMotion Message: 5864 From: Tom Kerekes Date: 10/23/2012
Subject: Re: KMotion Is Laughing At Me Again....
Hi Ray,
 
That is strange.  There are two mutex locks in the system.  They contain the thread number+1 of who owns printing.  I was going to ask you to print them out then next time it fails.  But heh, heh, that would never work.  Instead run this:
 
include "KMotionDef.h"
extern int PrintMutex;
extern int PrintfMutex;
main()
{
 ch7->Dest = PrintMutex *1000 + PrintfMutex;
}
and look at the axis 7 destination on the Axis Screen.
 
Regards
TK